package v1

import (
	"gin-vue-admin/global"
	"gin-vue-admin/model"
	"gin-vue-admin/model/request"
	"gin-vue-admin/model/response"
	"gin-vue-admin/service"
	"github.com/gin-gonic/gin"
	"go.uber.org/zap"
)

// CreateFakeDetectResult 创建FakeDetectResult
// @Tags FakeDetect
// @Summary 创建FakeDetectResult
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.FakeDetect true "创建FakeDetectResult"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /res/createFakeDetectResult [post]
func CreateFakeDetectResult(c *gin.Context) {
	var res model.FakeDetect
	_ = c.ShouldBindJSON(&res)
	if err := service.CreateFakeDetectResult(res); err != nil {
		global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
		response.FailWithMessage("创建失败", c)
	} else {
		response.OkWithMessage("创建成功", c)
	}
}

// DeleteFakeDetectResult 删除FakeDetectResult
// @Tags FakeDetect
// @Summary 删除FakeDetectResult
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.FakeDetect true "删除FakeDetectResult"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /res/deleteFakeDetectResult [delete]
func DeleteFakeDetectResult(c *gin.Context) {
	var res model.FakeDetect
	_ = c.ShouldBindJSON(&res)
	if err := service.DeleteFakeDetectResult(res); err != nil {
		global.GVA_LOG.Error("删除失败!", zap.Any("err", err))
		response.FailWithMessage("删除失败", c)
	} else {
		response.OkWithMessage("删除成功", c)
	}
}

// DeleteFakeDetectResultByIds 批量删除FakeDetectResult
// @Tags FakeDetect
// @Summary 批量删除FakeDetectResult
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.IdsReq true "批量删除FakeDetectResult"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"批量删除成功"}"
// @Router /res/deleteFakeDetectResultByIds [delete]
func DeleteFakeDetectResultByIds(c *gin.Context) {
	var IDS request.IdsReq
	_ = c.ShouldBindJSON(&IDS)
	if err := service.DeleteFakeDetectResultByIds(IDS); err != nil {
		global.GVA_LOG.Error("批量删除失败!", zap.Any("err", err))
		response.FailWithMessage("批量删除失败", c)
	} else {
		response.OkWithMessage("批量删除成功", c)
	}
}

// UpdateFakeDetectResult 更新FakeDetectResult
// @Tags FakeDetect
// @Summary 更新FakeDetectResult
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.FakeDetect true "更新FakeDetectResult"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"更新成功"}"
// @Router /res/updateFakeDetectResult [put]
func UpdateFakeDetectResult(c *gin.Context) {
	var res model.FakeDetect
	_ = c.ShouldBindJSON(&res)
	if err := service.UpdateFakeDetectResult(res); err != nil {
		global.GVA_LOG.Error("更新失败!", zap.Any("err", err))
		response.FailWithMessage("更新失败", c)
	} else {
		response.OkWithMessage("更新成功", c)
	}
}

// FindFakeDetectResult 用id查询FakeDetectResult
// @Tags FakeDetect
// @Summary 用id查询FakeDetectResult
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body model.FakeDetect true "用id查询FakeDetectResult"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"查询成功"}"
// @Router /res/findFakeDetectResult [get]
func FindFakeDetectResult(c *gin.Context) {
	var res model.FakeDetect
	_ = c.ShouldBindQuery(&res)
	if err, res := service.GetFakeDetectResult(res.ID); err != nil {
		global.GVA_LOG.Error("查询失败!", zap.Any("err", err))
		response.FailWithMessage("查询失败", c)
	} else {
		response.OkWithData(res, c)
	}
}

// GetFakeDetectResultList 分页获取FakeDetectResult列表
// @Tags FakeDetect
// @Summary 分页获取FakeDetectResult列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body request.FakeDetectResultSearch true "分页获取FakeDetectResult列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /res/getFakeDetectResultList [get]
func GetFakeDetectResultList(c *gin.Context) {
	var pageInfo request.FakeDetectResultSearch
	_ = c.ShouldBindQuery(&pageInfo)
	if err, list, total := service.GetFakeDetectResultInfoList(pageInfo); err != nil {
		global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
		response.FailWithMessage("获取失败", c)
	} else {
		response.OkWithDetailed(response.PageResult{
			List:     list,
			Total:    total,
			Page:     pageInfo.Page,
			PageSize: pageInfo.PageSize,
		}, "获取成功", c)
	}
}
